<CFQUERY NAME="getclient" DATASOURCE="#dsn#">
select *
from tblcustomers
where CustomerNum = <cfqueryparam cfsqltype="cf_sql_integer" value="#accountnumber#">

</CFQUERY>

<cfif isdefined("session.ReceiptNum")>
<CFQUERY NAME="getorders" DATASOURCE="#dsn#">
select *
from tblorders
where ReceiptNum = #session.ReceiptNum#
</CFQUERY>

<CFQUERY NAME="getitems" DATASOURCE="#dsn#">
select *
from tbltransactions, tblproducts
where ReceiptNum = #session.ReceiptNum# and tbltransactions.ProdID = tblproducts.ProdID
</CFQUERY>

<CFQUERY NAME="getitemssum" DATASOURCE="#dsn#">
select sum(Price) as total, sum(TaxAmount) as totaltax
from tbltransactions
where ReceiptNum = #session.ReceiptNum#
</CFQUERY>

<CFIF #getitemssum.total# LTE 0>
<CFSET getitemssum.total = 0>
</CFIF>

<CFIF #getitemssum.totaltax# LTE 0>
<CFSET getitemssum.totaltax = 0>
</CFIF>


<CFSET TOTAMOUNT = #getitemssum.total# + #getitemssum.totaltax#>

<cfif isdefined("session.TransType") and #session.TransType# eq "VOID"><CFSET FORMPATH = "void.cfm"><cfelse><CFSET FORMPATH = "addtocart.cfm"></cfif>


<!---update order with amount..............................--->
<cfif getitemssum.total gte 1>

<CFQUERY DATASOURCE="#dsn#">
update tblorders
set Amount = #getitemssum.total#
where ReceiptNum = #session.ReceiptNum#
</CFQUERY>

</cfif>

<cfelse>
<CFQUERY NAME="getorders" DATASOURCE="#dsn#"> 
select *
from tblorders
where ReceiptNum = 0
</CFQUERY>
<cfset getitems.recordcount = 0>
<cfset getitemssum.total = 0>
<cfset getitemssum.totaltax = 0>
<CFSET FORMPATH = "createinvoice.cfm">

</cfif>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
#container {
	width:650px;
	height:450px;
	text-align:center;
}
#myform {
	position:relative;
	float:left;
	top:4px;
	width:648px;
	height:53px;
	z-index:1;
	text-align:left;
	left: 0;
}
.style1 {font-size:18px;
color:#000;
}
.style6 {font-size:24px;
color:#000;
}
#items {
	position:relative;
	float:left;
	top:10px;
	width:648px;
	height:325px;
	z-index:2;
	overflow: hidden;
	left: 0;
}
body,td,th {
	font-family: Verdana, Geneva, sans-serif;
	font-size: 12px;
}
#total {
	position:relative;
	float:left;
	top:75px;
	width:648px;
	height:50px;
	z-index:3;
	left: 0;
}
#alert{
position:absolute;
z-index:1;
border:1px double #333;
background:#eeeeee;
width:300px;
height:100px;
margin-top:-150px;
margin-left:-150px;
top:50%;
left:50%;
text-align:center;
font-family:"Trebuchet MS", verdana, arial,tahoma;
font-size:18pt;


}
	
-->
</style></head>

<body onLoad="document.form1.ProdID.focus()" background-repeat:repeat-x;margin:0px auto;text-align:left; bgcolor="#FFFFFF">



<div id="container"><div id="myform">
  <cfoutput>
      <cfform name="form1" id="form1" method="post" action="#FORMPATH#"><table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td valign="middle" bgcolor="##FFFFFF"><span class="style1">QTY:
      <cfinput type="text" name="QTY" class="style1" style="border-color:transparent; background-color:##eeeeee" size="3" value="1">
    </span></td>
    <td valign="middle" bgcolor="##FFFFFF">
    <label>
      <span class="style1">UPC:</span>
      <cfif isdefined("session.prodid")><cfinput type="text" name="ProdID" class="style1" style="border-color:transparent; background-color:##eeeeee" size="20" value="#session.prodid#" onblur="form1.submit()"><cfelse><cfinput type="text" name="ProdID" class="style1" style="border-color:transparent; background-color:##eeeeee" size="20" onChange="form1.submit()"></cfif><cfinput type="image" name="submit" src="images/submit.png" onClick="form1.submit()">
    </label> </td>
    <td align="right">
      <cfif isdefined("session.TransType")>
        <cfif #session.TransType# eq "VOID"><strong><font color="##FF0000">#session.TransType#</font></strong><cfelse><strong>#session.TransType#</strong></cfif>
        <cfelse>SALE</cfif>
       | Inv: 
        <cfif isdefined("session.receiptnum")>#session.receiptnum#<cfelse>N/A</cfif> <cfif isdefined("session.receiptnum")><CFIF #getorders.DODAAC# neq "">| Cust Num: #getorders.DODAAC#</CFIF></cfif></td>
  </tr>
</table> 
      </cfform></cfoutput>

</div>
  <div id="items">
    <cfif isdefined("url.message")><div id="alert"><cfoutput><br />#message#</cfoutput></div></cfif><table width="100%" border="1" cellspacing="0" cellpadding="2" bordercolor="#eeeeee">
      <tr>
        <td width="10%" height="20" align="center" valign="middle" bgcolor="#eeeeee">Item</td>
        <td width="43%" height="20" align="left" valign="middle" bgcolor="#eeeeee">Description</td>
        <td width="10%" height="20" align="center" valign="middle" bgcolor="#eeeeee">Qty</td>
        <td width="14%" height="20" align="center" valign="middle" bgcolor="#eeeeee">Tax</td>
        <td width="15%" height="20" align="left" valign="middle" bgcolor="#eeeeee">Price</td>
      </tr>
       <cfif getitems.recordcount gte 1><cfoutput query="getitems"><CFQUERY NAME="getTAX" DATASOURCE="#dsn#">
select *
from tblproducts
where ProdID = '#ProdID#'
</CFQUERY><tr>
        <td height="25" align="center">#ProdID#</td> 
        <td height="25">#ProductName#&nbsp;</td>
        <td height="25" align="center">#qty#</td>
        <td height="25" align="center"><CFIF #getTAX.TaxAmount# gte 1>T<cfelse>&nbsp;</CFIF></td>
        <td height="25">#LSCURRENCYFORMAT(price)#</td>
      </tr></cfoutput><cfelse><tr>
        <td height="25">&nbsp;</td>
        <td height="25">&nbsp;</td>
        <td height="25" align="center">0</td>
        <td height="25" align="center">N/A</td>
        <td height="25">$0.00</td>
      </tr></cfif>
    </table>
  </div>
  <div id="total">
  <table width="100%" border="0" cellspacing="0" cellpadding="2">
  <tr class="style1">
    <td width="12%" height="35" align="right">Sub Total:</td>
    <td width="22%" align="left"><strong><cfoutput>
      <CFIF #getitemssum.total# lte 0>$0.00<cfelse>#LSCURRENCYFORMAT(getitemssum.total)#</CFIF></cfoutput></strong></td>
    <td width="14%" height="35" align="right">Total Tax:</td>
    <td width="25%" height="35" align="left"><strong><cfoutput>
      <CFIF #getitemssum.totaltax# lte 0>$0.00<cfelse>#LSCURRENCYFORMAT(getitemssum.totaltax)#</CFIF></cfoutput></strong></td>
    <td width="10%" height="35" align="right">Total: </td>
    <td width="17%" height="35" align="left"><strong><cfoutput>
      <CFIF #getitemssum.total# lte 0>$0.00<cfelse>#LSCURRENCYFORMAT(TOTAMOUNT)#</CFIF></cfoutput></strong></td>
  </tr>
</table>
</div>
</div>
</body>
</html>